HAL DAC types migration ¶
This section provides information about the HAL DAC types migration.
HAL DAC state type definition ¶
In HAL2, the state machine of the DAC is split into two separate state machines:
hal_dac_state_tandhal_dac_channel_state_t.
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_DAC_STATE_RESET
HAL_DAC_STATE_READY
HAL_DAC_STATE_BUSY
HAL_DAC_STATE_TIMEOUT
HAL_DAC_STATE_ERROR
} HAL_DAC_StateTypeDef;
|
typedef enum
{
HAL_DAC_STATE_RESET
HAL_DAC_STATE_SEPARATE_CHANNEL_CONFIGURED
HAL_DAC_STATE_DUAL_CHANNEL_CONFIGURED
HAL_DAC_STATE_DUAL_CHANNEL_ACTIVE
} hal_dac_state_t;
typedef enum
{
HAL_DAC_CHANNEL_STATE_RESET
HAL_DAC_CHANNEL_STATE_IDLE
HAL_DAC_CHANNEL_STATE_ACTIVE
HAL_DAC_CHANNEL_STATE_ACTIVE_SILENT
} hal_dac_channel_state_t;
|
Related concept: Revised and optimized HAL state machine
HAL DAC callback ID type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_DAC_CH1_COMPLETE_CB_ID
HAL_DAC_CH1_HALF_COMPLETE_CB_ID
HAL_DAC_CH1_ERROR_ID
HAL_DAC_CH1_UNDERRUN_CB_ID
HAL_DAC_CH2_COMPLETE_CB_ID
HAL_DAC_CH2_HALF_COMPLETE_CB_ID
HAL_DAC_CH2_ERROR_ID
HAL_DAC_CH2_UNDERRUN_CB_ID
HAL_DAC_MSPINIT_CB_ID
HAL_DAC_MSPDEINIT_CB_ID
HAL_DAC_ALL_CB_ID
} HAL_DAC_CallbackIDTypeDef;
|
Removed . Note The callback registration in HAL2 is handled by specific functions for each DAC event. These functions are used to register callback functions for different DAC events. See HAL DAC callbacks register and unregister functions for more details. |
Related concept: Individual callback registration APIs replace global register and unregister functions
HAL DAC configuration type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t DAC_SampleTime ;
uint32_t DAC_HoldTime ;
uint32_t DAC_RefreshTime ;
} DAC_SampleAndHoldConfTypeDef;
|
typedef struct
{
uint32_t sample_time_cycle;
uint32_t hold_time_cycle;
uint32_t refresh_time_cycle;
} hal_dac_channel_sample_and_hold_config_t;
|
Related concepts: - Replaced TypeDef suffix with _t in type names - Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).
HAL DAC channel configuration type definition ¶
In HAL2, the DAC configuration is split into three separate structures:
hal_dac_config_t,hal_dac_channel_config_tandhal_dac_channel_sample_and_hold_config_t.
Note
The DAC data alignment constants in HAL1 are arguments used when calling the API.
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t DAC_HighFrequency;
uint32_t DAC_AutonomousMode;
FunctionalState DAC_SignedFormat;
uint32_t DAC_Trigger;
uint32_t DAC_OutputBuffer;
uint32_t DAC_ConnectOnChipPeripheral ;
uint32_t DAC_SampleAndHold;
uint32_t DAC_UserTrimming;
uint32_t DAC_TrimmingValue;
DAC_SampleAndHoldConfTypeDef DAC_SampleAndHoldConfig;
FunctionalState DAC_DMADoubleDataMode;
} DAC_ChannelConfTypeDef;
|
typedef struct
{
hal_dac_high_freq_mode_t high_frequency_mode;
} hal_dac_config_t;
HAL_DAC_AM_Enable(hal_dac_handle_t *hdac);
HAL_DAC_AM_Disable(hal_dac_handle_t *hdac);
typedef struct
{
hal_dac_sign_format_t data_sign_format;
hal_dac_trigger_t trigger;
hal_dac_output_buffer_status_t output_buffer;
hal_dac_output_connection_t output_connection;
hal_dac_data_alignment_t alignment;
} hal_dac_channel_config_t;
hal_status_t HAL_DAC_EnableChannelSampleAndHold(hal_dac_handle_t *hdac,
hal_dac_channel_t channel);
hal_status_t HAL_DAC_DisableChannelSampleAndHold(hal_dac_handle_t *hdac,
hal_dac_channel_t channel);
hal_status_t HAL_DAC_SetChannelBufferCalibrationValue(hal_dac_handle_t *hdac,
hal_dac_channel_t channel,
uint32_t value);
typedef struct
{
uint32_t sample_time_cycle;
uint32_t hold_time_cycle;
uint32_t refresh_time_cycle;
} hal_dac_channel_sample_and_hold_config_t;
hal_status_t HAL_DAC_SetConfigChannelSampleAndHold(hal_dac_handle_t *hdac,
hal_dac_channel_t channel,
const hal_dac_channel_sample_and_hold_config_t *p_config);
hal_status_t HAL_DAC_EnableChannelDMADoubleDataMode(hal_dac_handle_t *hdac,
hal_dac_channel_t channel);
hal_status_t HAL_DAC_DisableChannelDMADoubleDataMode(hal_dac_handle_t *hdac,
hal_dac_channel_t channel);
|
Related concept: Removal and conversion of init structure to configuration structure
HAL DAC autonomous mode configuration type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t AutonomousModeState;
} DAC_AutonomousModeConfTypeDef;
|
/* In HAL2, the DAC autonomous mode state is managed by unitary functions in the HAL layer */
HAL_DAC_AM_Enable(hal_dac_handle_t *hdac);
HAL_DAC_AM_Disable(hal_dac_handle_t *hdac);
|
HAL DAC handle type definition ¶
|
HAL1 |
HAL2 |
|---|---|
DAC_HandleTypeDef
|
hal_dac_handle_t
|
Related concept: Renaming of the handle structure
HAL DAC callback type definition ¶
|
HAL1 |
HAL2 |
|---|---|
|
pDAC_CallbackTypeDef |
hal_dac_cb_t |
Related concept: Replaced TypeDef suffix with _t in type names